pkg_name=cross-binutils
version=2.25
build_dir=$builds_dir_root/$pkg_name-$version
src_dir=$src_dir_root/binutils-$version
url=http://ftpmirror.gnu.org/binutils/binutils-$version.tar.bz2

rm -Rf "$src_dir"
cd "$src_dir_root"
tar jxf "binutils-$version.tar.bz2"

cd "$src_dir/bfd/doc"
cp "$builders_dir_root/$pkg_name/bfd-doc-Makefile.in.patch" ./Makefile.in.patch
patch -Ni ./Makefile.in.patch

rm -Rf "$build_dir"
mkdir -p "$build_dir"
cd "$build_dir"

export CFLAGS=-O0
"$src_dir/configure"			\
	--target=$gnu_target		\
	"--prefix=$cross_dir_root"	\
	"--with-gmp=$cross_dir_root"	\
	"--with-mpfr=$cross_dir_root"	\
	"--with-mpc=$cross_dir_root"	\
	"--with-sysroot=$sysroot"	\
	--enable-host-shared		\
	--disable-gold			\
	--disable-multilib		\
	--disable-nls
unset CFLAGS

make

install_tmp_dir=/tmp/$pkg_name-$version
rm -Rf "$install_tmp_dir"
mkdir -p "$install_tmp_dir"
make install "DESTDIR=$install_tmp_dir"

install_dirs_with_prefix "$builders_dir_root/$pkg_name/runtime.dirs" "$cross_dir_root/"
install_files_with_prefix "$builders_dir_root/$pkg_name/runtime.files" "$install_tmp_dir" "$cross_dir_root/"
elf_strip_with_prefix "$builders_dir_root/$pkg_name/elf-strip" "$cross_dir_root/"

rm -Rf "$install_tmp_dir"
rm -Rf "$build_dir"
rm -Rf "$src_dir"
